IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[or_UserProfileInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE dbo.[or_UserProfileInsert]
Go

CREATE  PROCEDURE  dbo.[or_UserProfileInsert]  
	@UserProfileID  int,
	@MeMaUserID  nvarchar(100),
	@MentorStatusTypeID  int,
	@MentorRating  int,
	@LinkedInLink  nvarchar(1000),
	@FacebookLink  nvarchar(1000),
	@TwitterHandle  nvarchar(1000),
	@PersonalWebsite  nvarchar(1000),
	@Summary  nvarchar(max) 

AS  
  
  declare @DateTime datetime,@TranCountAtEntry int
  select @DateTime = getdate() 
BEGIN TRY 

IF @TranCountAtEntry  = 0 
BEGIN TRANSACTION 

INSERT INTO UserProfile(
MeMaUserID, 
Picture, 
MentorStatusTypeID, 
MentorRating, 
LinkedInLink, 
FacebookLink, 
TwitterHandle, 
PersonalWebsite, 
Summary, 
LastModDate, 
CreatedDate
)
VALUES (
@MeMaUserID, 
null, 
@MentorStatusTypeID, 
@MentorRating, 
@LinkedInLink, 
@FacebookLink, 
@TwitterHandle, 
@PersonalWebsite, 
@Summary, 
@DateTime, 
@DateTime
)
 
IF @@TRANCOUNT > @TranCountAtEntry
COMMIT TRANSACTION

END TRY
BEGIN CATCH
  
  IF @@TRANCOUNT > @TranCountAtEntry
  ROLLBACK TRANSACTION

  -- Raise an error with the details of the exception
  or_raiseerror 

END CATCH
  
  